<?php
class tpl_edit {
	function call($toObj) {
		$yData = Y('Module.List.Editor.YML', Y('Module.List.Editor.Op'));
		$fData = Y('Module.List.Editor.Data');

		$Form = $toObj->DOG_appendChild('form')->attr(array(
			'id'=>'EditorForm',
			'name'=>'EditorForm',
			'method'=>'post',
			'action'=>Y('Request.SERVER.REQUEST_URI')
		));
		
		$DL = $Form->DOG_appendChild('dl');
		$Cnt = 1;
		foreach ($ListItems = (array)Y('Module.List.Editor.YML', 'validate') as $Key=>$ListItem) {
			if (empty($ListItem['form']) || !strcasecmp('no',$ListItem['form'])) continue;
		
			$ListItem['Name'] = $Key;
			$ListItem['TabIndex'] = $Cnt;
			$ListItem['Value'] = isset($fData[0][$Key])?($fData[0][$Key]):(isset($ListItem['default'])?($ListItem['default']):(null));
			
			$Cnt++;
		
			$DT = $DL->DOG_appendChild('dt')->attr(array('class'=>$ListItem['form']));
			$DT->DOG_appendChild('label')->attr(array('for'=>$ListItem['Name']))->text($ListItem['string']);

			$DD = $DL->DOG_appendChild('dd')->attr(array('class'=>'Form '.$ListItem['form']));
			Y('Module.List.Editor.Form+', $ListItem); 
			Y('document.load', 'Editor:form/'.$ListItem['form'], $DD);

			if (isset($ListItem['description'])) {
				$DD = $DL->DOG_appendChild('dd')->attr(array('class'=>'description'));
				$DD->append($ListItem['description']);
			}
		}

	}
}

/*
<dl>
<?php
?>
</dl>
</form>

<?php Y('Module.LoadAction', 'objTree'); */?>
